// @formatter:off
/**
 * @file mdefault.js
 * @author Alejandro Dario Simi
 * @date $Date: 2013-05-19 06:39:24 +0000 (Sun, 19 May 2013) $
 *
 * $Id: mdefault.js 65 2013-05-19 06:39:24Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA1/themes/mdefault/mdefault.js $
 */
// @formatter:on

function LogOut(service) {
	jQuery.post('service.php?action=' + service, function(data) {
		var xml = $($.parseXML(data));
		if(xml.find("wc-success").length) {
			SelfReload();
		} else if(xml.find("wc-failed").length) {
			var error = "";
			if(xml.find("wc-error>wc-code").length) {
				error = "[" + xml.find("wc-error>wc-code").text() + "] ";
			}
			error = error + xml.find("wc-error>wc-message").text();

			alert("Failed: " + error);
		}
	});
}

function ReloadHome() {
	window.location.href = '?group=' + GROUP_ID;
}

function SelfReload() {
	window.location.reload();
}

function SetMobile(service, status) {
	jQuery.post('service.php?action=' + service + '&mobile=' + ( status ? 'on' : 'off'), function(data) {
		var xml = $($.parseXML(data));
		if(xml.find("wc-success").length) {
			ReloadHome();
		} else if(xml.find("wc-failed").length) {
			var error = "";
			if(xml.find("wc-error>wc-code").length) {
				error = "[" + xml.find("wc-error>wc-code").text() + "] ";
			}
			error = error + xml.find("wc-error>wc-message").text();

			alert("Failed: " + error);
		}
	});
}
